// pages/myplan/myplan.js
const app = getApp()
Page({
  data: {
    list: [],
    height: 800,
    id:'',
    showModal: false,
    dialogTitle: '',
    dialogContent: '',
    item:{},

  },
  onLoad: function (options) {
    //hgz/demand/queryListWithPage
    var id = options.id;
    var windowHeight = app.globalData.windowHeight;
    this.setData({
      height: windowHeight - 240,
      id: id
    })
  },
  onShow() {
    app.request.postHeadForm('hgz/post/showById/'+this.data.id)
      .then(res => {
        var dataList = res.data.replayVoList;
        this.setData({
          list: dataList,
          item:res.data
        })
      })
  },
  onConfirm() {
    var params = {
      postId:this.data.id,
      content: this.data.dialogContent,
    }
    if (this.data.dialogContent == '') {
      wx.showToast({
        title: '内容不能为空',
        icon: 'none',
        duration: 1000
      })
      return;
    }
    wx.showLoading({
      title: '加载中',
    })
    app.request.postHeadJson('hgz/replay/save', params).then(res => {
      wx.hideLoading();
      if (res.status) {
        wx.showToast({
          title: '回帖成功',
          icon: 'none',
          duration: 1000
        })
        this.onShow();
        this.setData({
          dialogContent:'',
          showModal: false
        })
      } else {
        wx.showToast({
          title: '' + res.message,
          icon: 'none',
          duration: 1000
        })
      }
    })

  },
  submit() {
    this.setData({
      showModal: true
    })
  },
  inputChange2(e) {
    this.setData({
      dialogContent: e.detail.value
    })
  },
  onCancel() {
    this.setData({
      showModal: false
    })
  },
  preventTouchMove: function () {

  }

})